﻿using LayIM.AspNetCore.Core.Routes;
using System;
using System.Collections.Generic;
using System.Text;

namespace LayIM.AspNetCore.Core.Razor
{
    internal class FindPage : RazorPage
    {
        public FindPage()
        {

        }

        public override void Execute()
        {
            WriteLiteral("<head>\r\n");

            WriteLiteral("<meta charset=\"utf-8\">\r\n");
            WriteLiteral("<title>查找好友/群组</title>\r\n");
            WriteCss("/css/layui.css");
            WriteLiteral(@"<style>
                            body {
                                height: auto;
                            }

                            .search {
                                width: 100%;
                                height: 50px;
                            }

                            .ml_10 {
                                margin-left: 10px;
                            }

                            .findFriend, .findGroup {
                                width: 100px;
                                letter-spacing: 6px;
                            }

                            .recordList {
                                padding: 0px;
                                min-height: 365px;
                            }

                                .recordList .demo-list .layui-card {
                                    height: 100px;
                                }

                            .avatar {
                                width: 100px;
                                float: left;
                            }

                                .avatar img {
                                    border-radius: 50%;
                                    width: 60px;
                                    height: 60px;
                                    margin: 20px;
                                }

                            .units {
                                float: left;
                                font-size: 12px;
                                line-height: 20px;
                                padding-top: 16px;
                            }

                            .line {
                                padding: 0 10px;
                                color: #ccc;
                            }

                            .icons {
                                font-size: 12px;
                                color: #888;
                            }

                            .addFriend {
                                background-color: #7ADDD4;
                            }
                        </style>");

            WriteLiteral("</head>");

            WriteLiteral("<div class=\"layui-card\" style=\"margin-bottom:0px;\">\r\n");
            WriteLiteral("<div class=\"layui-tab layui-tab-brief layadmin-latestData\">\r\n");
            WriteLiteral("<ul class=\"layui-tab-title\">\r\n");
            WriteLiteral("<li class=\"layui-this\">找人</li>\r\n");
            WriteLiteral("<li>群聊</li>\r\n");
            WriteLiteral("</ul>\r\n");
            WriteLiteral("<div class=\"layui-tab-content\" style=\"padding-bottom:0px;\">\r\n");

            WriteLiteral("<div class=\"layui-tab-item layui-show\">\r\n");
            WriteLiteral("<div class=\"layui-row layui-col-space15\">\r\n");
            WriteLiteral("<div class=\"layui-form\">\r\n");
            WriteLiteral("<div class=\"search\">\r\n");
            WriteLiteral("<div class=\"layui-col-md4\">\r\n");
            WriteLiteral("<input type=\"text\" id=\"searchKey1\" placeholder=\"请输入姓名搜索\" autocomplete=\"off\" class=\"layui-input\">\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("<div class=\"layui-col-md2\" style=\"margin-left:10px;\">\r\n");
            WriteLiteral("<button class=\"findFriend layui-btn\">查找</button>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("<div class=\"recordList\">\r\n");
            WriteLiteral("<div id=\"friendList\" class=\"layui-row layui-col-space10 demo-list\"></div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");

            WriteLiteral("<div class=\"layui-tab-item\">\r\n");
            WriteLiteral("<div class=\"layui-row layui-col-space15\">\r\n");
            WriteLiteral("<div class=\"layui-form\">\r\n");
            WriteLiteral("<div class=\"search\">\r\n");
            WriteLiteral("<div class=\"layui-col-md4\">\r\n");
            WriteLiteral("<input type=\"text\" id=\"searchKey2\" placeholder=\"请输入群名称搜索\" autocomplete=\"off\" class=\"layui-input\">\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("<div class=\"layui-col-md2\" style=\"margin-left:10px;\">\r\n");
            WriteLiteral("<button class=\"findFriend layui-btn\">查找</button>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("<div class=\"recordList\">\r\n");
            WriteLiteral("<div id=\"groupList\" class=\"layui-row layui-col-space10 demo-list\"></div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");

            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");


            WriteLiteral("<textarea title=\"用户模版\" id=\"LAY_Friend\" style=\"display:none;\">\r\n");
            WriteLiteral("{{# layui.each(d.data, function(index, item){ }}\r\n");
            WriteLiteral("<div class=\"layui-col-sm4 layui-col-md4 layui-col-lg2\">\r\n");
            WriteLiteral("<div class=\"layui-card\">\r\n");
            WriteLiteral("<div class=\"avatar\">\r\n");
            WriteLiteral("<img class=\"layadmin-homepage-pad-img\" src=\"{{ item.avatar }}\" />\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("<div class=\"units\">\r\n");
            //WriteLiteral("<p>{{ item.username }}({{ item.userCode }})</p>\r\n");
            WriteLiteral("<p>{{ item.username }}</p>\r\n");
            WriteLiteral("<p>{{ item.roleNames }}</p>\r\n");
            WriteLiteral("<p>\r\n");
            WriteLiteral("{{# if(item.isValid == 0){ }}\r\n");
            WriteLiteral("<button userId=\"{{ item.id }}\" userName=\"{{ item.username }}\" avatar=\"{{ item.avatar }}\" class=\"addFriend layui-btn layui-btn-xs\" style=\"background-color:#7ADDD4;\">&nbsp;&nbsp;<strong>+</strong>&nbsp;&nbsp;好友&nbsp;&nbsp;</button>\r\n");
            WriteLiteral("{{# } else { }}\r\n");
            WriteLiteral("<span class=\"c_red\">已经是好友</span>\r\n");
            WriteLiteral("{{# } }}\r\n");
            WriteLiteral("</p>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("{{# }); }}\r\n");
            WriteLiteral("</textarea>\r\n");


            WriteLiteral("<textarea title=\"群聊模版\" id=\"LAY_Group\" style=\"display:none;\">\r\n");
            WriteLiteral("{{# layui.each(d.data, function(index, item){ }}\r\n");
            WriteLiteral("<div class=\"layui-col-sm4 layui-col-md4 layui-col-lg2\">\r\n");
            WriteLiteral("<div class=\"layui-card\">\r\n");
            WriteLiteral("<div class=\"avatar\">\r\n");
            WriteLiteral("<img class=\"layadmin-homepage-pad-img\" src=\"{{ item.avatar }}\" />\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("<div class=\"units\">\r\n");
            WriteLiteral("<p style=\"font-size: 14px;\">{{ item.groupname }}</p>\r\n");
            WriteLiteral("<p><i class=\"layui-icon layui-icon-group icons\"></i> {{ item.userCount }}<span class=\"line\">|</span><i class=\"layui-icon layui-icon-friends icons\"></i>{{ item.username }}</p>\r\n");
            WriteLiteral("<p>\r\n");
            WriteLiteral("{{# if(item.isJoin == 0){ }}\r\n");
            WriteLiteral("<button groupId=\"{{ item.id }}\" groupName=\"{{ item.groupname }}\" userId=\"{{ item.userid }}\" avatar=\"{{ item.avatar }}\" class=\"addGroup layui-btn layui-btn-xs\" style=\"background-color:#7ADDD4;\">&nbsp;&nbsp;<strong>+</strong>&nbsp;&nbsp;加群&nbsp;&nbsp;</button>\r\n");
            WriteLiteral("{{# } else { }}\r\n");
            WriteLiteral("<span class=\"c_red\">已经是群成员</span>\r\n");
            WriteLiteral("{{# } }}\r\n");
            WriteLiteral("</p>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("</div>\r\n");
            WriteLiteral("{{# }); }}\r\n");
            WriteLiteral("</textarea>");

            WriteJs("/js/jquery.js");
            WriteJs("/js/find.js");

            WriteLiteral($"<script>findParam.init('{LayIMUrls.BuildUrl(LayIMUrls.LAYIM_ROUTE_IM_MEMBERS)}','{LayIMUrls.BuildUrl(LayIMUrls.LAYIM_ROUTE_IM_GROUPS)}');</script>\r\n");
        }
    }
}
